@(year:Int, month:Int, accountingRows: List[AccountingRow], recipeCategories: List[Category], expenseCategories: List[Category])
@import utils.DateUtils
@import java.text.SimpleDateFormat
@import play.i18n._



@main("By month") {

    <h1>@{DateUtils.month(month)} @{year}</h1>

    <table class="table table-bordered">
        <thead>
            <tr>
                <th rowspan="2">@Messages.get("accountingRow.day")</th>
                <th rowspan="2">@Messages.get("accountingRow.label")</th>
                <th class="recipe" colspan="@{recipeCategories.size}">@Messages.get("rowType.recipe")</th>
                <th class="expense" colspan="@{expenseCategories.size}">@Messages.get("rowType.expense")</th>
            </tr>
            <tr>
            @for(recipeCategory <- recipeCategories) {
                <th class="recipe">@{recipeCategory.name}</th>
            }
            @for(expenseCategory <- expenseCategories) {
                <th class="expense">@{expenseCategory.name}</th>
            }
            </tr>
        </thead>
        <tfoot>
            <tr class="important">
                <td colspan="2">Totaux du mois</td>
                @for(recipeCategory <- recipeCategories) {
                    <td class="recipe">@{recipeCategory.monthSum(year, month)}</td>
                }
                @for(expenseCategory <- expenseCategories) {
                    <td class="expense">@{expenseCategory.monthSum(year, month)}</td>
                }
            </tr>
        @if(month > 1){
            <tr class="important">
                <td colspan="2">Totaux depuis janvier</td>
                @for(recipeCategory <- recipeCategories) {
                    <td class="recipe">@{recipeCategory.fromJanuarySum(year, month)}</td>
                }
                @for(expenseCategory <- expenseCategories) {
                    <td class="expense">@{expenseCategory.fromJanuarySum(year, month)}</td>
                }
            </tr>
        }
        </tfoot>
        <tbody>
        @if(month > 1){
            <tr class="notice">
                <td>#</td>
                <td>Report</td>
                @for(recipeCategory <- recipeCategories) {
                    <td class="recipe">@{recipeCategory.fromJanuarySum(year, month-1)}</td>
                }
                @for(expenseCategory <- expenseCategories) {
                    <td class="expense">@{expenseCategory.fromJanuarySum(year, month-1)}</td>
                }
            </tr>
        }
        @for(accountingRow <- accountingRows) {
            <tr>
                <td>@if(accountingRow.date != null){@accountingRow.date.format("dd")}</td>
                <td>@accountingRow.label</td>
            @for(recipeCategory <- recipeCategories) {
                <td class="recipe">@if(accountingRow.category==recipeCategory){@{accountingRow.amount}}</td>
            }
            @for(expenseCategory <- expenseCategories) {
                <td class="expense">@if(accountingRow.category==expenseCategory){@{accountingRow.amount}}</td>
            }
            </tr>
        }
        </tbody>
    </table>

    <div class="navbar navbar-fixed-bottom">
        <div class="navbar-inner">
            <div class="container">
                <ul class="nav">
                    @for(m <- 1 to 12) {
                        <li @if(m == month){class="active"}><a href="@routes.Accounting.byMonth(year,m)">@{DateUtils.shortMonth(m)}</a></li>
                    }
                </ul>
            </div>
        </div>
    </div>
}
